package cc.rengu.redp.common.utils;

import org.apache.commons.lang3.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexUtil {

    /**
     * 验证是否http地址或https地址
     * @param urls
     * @return
     */
    public static boolean isHttp(String urls) {
        if(StringUtils.isBlank(urls)) {
            return  true;
        }
        String regex = "http(s?)\\:\\/\\/[0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*(:(0-9)*)*(\\/?)([a-zA-Z0-9\\-\\.\\?\\,\\'\\/\\\\&%\\+\\$#_=]*)?";
        Pattern pat = Pattern.compile(regex);
        Matcher mat = pat.matcher(urls.trim());
        boolean result = mat.matches();
        return result;
    }
}
